{if $action == 'my'}
{template 'header-widget', $module}
<form action="childcompany.php">
<input type="hidden" name="action" value="{$action}"/>
<input type="hidden" name="from" value="{$from}"/>
<div class="tt">
{$fields_select}&nbsp;
<input type="text" size="40" name="kw" value="{$kw}" title="关键词"/>&nbsp;
<input type="submit" value="搜 索" class="btn"/>
<input type="button" value="重 搜" class="btn" onclick="Go('childcompany.php?action={$action}&from={$from}');"/>
</div>
</form>
{if $lists}
<div class="ls">
<table cellpadding="0" cellspacing="0" class="tb">
<tr>
<th width="26"></th>
<th>公司</th>
<th>姓名</th>
<th>{if $from=='sms'}手机{else}会员{/if}</th>
{if $DT[im_web]}<th>在线</th>{/if}
<th><input type="checkbox" id="c_0" onclick="_check();"/></th>
</tr>
{loop $lists $k $v}
<tr onmouseover="this.className='on';" onmouseout="this.className='';" align="center" title="{$v[note]}">
<td><img src="{useravatar($v[username], 'small')}" width="20"/></td>
<td align="left">&nbsp;<a href="{userurl($v[username])}" target="_blank" class="t">{$v[company]}</a></td>
<td>{$v[truename]}</td>
<td id="v_{$v[itemid]}">{if $from=='sms'}{$v[mobile]}{else}{$v[username]}{/if}</td>
{if $DT[im_web]}<td>{im_web($v[username])}</td>{/if}
<td><input type="checkbox" id="c_{$v[itemid]}" onclick="_send({$v[itemid]});"/></td>
</tr>
{/loop}
</table>
</div>
{if $page}<div class="pages">{$pages}</div>{/if}
<div style="text-align:center;">
<input type="button" value="确 定" class="btn" onclick="window.parent.cDialog();"/>&nbsp;&nbsp;
<input type="button" value="关 闭" class="btn" onclick="window.parent.cDialog();"/>
</div>
<script type="text/javascript">
var itemids = [{loop $lists $i $t}{if $i},{/if}'{$t[itemid]}'{/loop}];
{if $from == 'sms'}
	function _send(id) {
		var v = Dd('v_'+id).innerHTML;
		if(parent.Dd('mob').value && parent.Dd('mob').value.indexOf("\n") == -1) parent.Dd('mob').value = parent.Dd('mob').value+"\n";
		if(Dd('c_'+id).checked) {
			if(parent.Dd('mob').value.indexOf(v) == -1) parent.Dd('mob').value = parent.Dd('mob').value+v+"\n";
		} else {
			if(parent.Dd('mob').value.indexOf(v) != -1) parent.Dd('mob').value = parent.Dd('mob').value.replace(v+"\n", '');
		}
	}
	function _check() {
		for(var i = 0; i < itemids.length; i++) {
			itemid = itemids[i];
			Dd('c_'+itemid).checked = Dd('c_0').checked ? true :false;
			_send(itemid);
		}
	}
	if(parent.Dd('mob').value) {
		s = parent.Dd('mob').value+"\n";
		for(var i = 0; i < itemids.length; i++) {
			itemid = itemids[i];
			f = Dd('v_'+itemid).innerHTML+"\n";
			if(s.indexOf(f) != -1) Dd('c_'+itemid).checked = true;
		}
	}
{else}
	var max = {$MOD[maxtouser]};
	function _send(id) {
		var v = Dd('v_'+id).innerHTML;
		if(parent.Dd('touser').value && parent.Dd('touser').value.indexOf(' ') == -1) parent.Dd('touser').value = parent.Dd('touser').value+' ';
		if(Dd('c_'+id).checked) {
			if(max && substr_count(parent.Dd('touser').value, ' ') >= max) {
				Dd('c_'+id).checked = false;
				return alert('最多可以选择'+max+'个收件人');
			}
			if(parent.Dd('touser').value.indexOf(v) == -1) parent.Dd('touser').value = parent.Dd('touser').value+v+' ';
		} else {
			if(parent.Dd('touser').value.indexOf(v) != -1) parent.Dd('touser').value = parent.Dd('touser').value.replace(v+' ', '');
		}
	}
	function _check() {
		for(var i = 0; i < itemids.length; i++) {
			itemid = itemids[i];
			if(Dd('c_0').checked) {
				if(max && substr_count(parent.Dd('touser').value, ' ') >= max) {
					break;
				} else {
					Dd('c_'+itemid).checked = true;
					_send(itemid);
				}
			} else {
				Dd('c_'+itemid).checked = false;
				_send(itemid);
			}
		}
	}
	if(parent.Dd('touser').value) {
		s = parent.Dd('touser').value+' ';
		for(var i = 0; i < itemids.length; i++) {
			itemid = itemids[i];
			f = Dd('v_'+itemid).innerHTML+' ';
			if(s.indexOf(f) != -1) Dd('c_'+itemid).checked = true;
		}
	}
{/if}
</script>
{else}
<center>{if $kw}未搜索到子公司{else}暂无子公司{/if}</center>
{/if}
</body>
</html>
{else}
{template 'header', $module}
<div class="menu">
<table cellpadding="0" cellspacing="0">
<tr>
<td class="tab" id="add"><a href="childcompany.php?action=add"><span>添加子公司</span></a></td>
<td class="tab" id="home"><a href="childcompany.php?action=index"><span>我的子公司</span></a></td>
<td class="tab" id="order_list"><a href="childcompany.php?action=order_list"><span>子公司订单</span></a></td>
</tr>
</table>
</div>

{if $action == 'order_list'}
<div class="tt">
    <form action="?">
        <input type="hidden" name="mid" value="{$mid}"/>
        <input type="hidden" name="status" value="{$status}"/>
        &nbsp;{category_select('catid', '行业分类', $catid, $moduleid)}&nbsp;
        {dselect($TYPE, 'typeid', '信息类型', $typeid)}&nbsp;
        <input type="text" size="50" name="kw" value="{$kw}" title="关键词"/>&nbsp;
        <input type="submit" value=" 搜 索 " class="btn"/>
        <input type="button" value=" 重 置 " class="btn" onclick="Go('?mid={$mid}&status={$status}');"/>
    </form>
</div>
<div class="nav">
    <table cellpadding="0" cellspacing="0">
        <tr>
            <td class="{if !in_array($nav, array(0,1,2))}nav_2{else}nav_1{/if}"><a href="?action={$action}">全部订单</a></td>
            <td class="{if $nav==0}nav_2{else}nav_1{/if}"><a href="?action={$action}&nav=0">待合并 <span>({$limit_used})</span></a></td>
            <td class="{if $nav==1}nav_2{else}nav_1{/if}"><a href="?action={$action}&nav=1">已合并 <span>({$limit_used1})</span></a></td>
            <td>&nbsp;</td>
        </tr>
    </table>
</div>

<div class="ls">
<form method="post">
<table cellpadding="8" cellspacing="0" class="tb">
    <tr bgcolor="#F2F2F2" align="center">
        {if $nav!=1}
        <th width="20"><input type="checkbox" onclick="checkall(this.form);"/></th>
        {/if}
        <th width="120">商品信息</th>
        <th width="120">过期时间</th>
        <th width="60">数量</th>
        <th width="120">订单金额</th>
        <th width="120">下单时间</th>
        <th width="120">子公司</th>
        <th width="120">订单状态</th>
    </tr>
{loop $lists $k $v}

    <tr align="center">
        {if $nav!=1}
        <td width="20">{if $v[status] == '3'}<input type="checkbox" name="itemid[]" value="{$v[itemid]}"/> {/if}</td>
        {/if}
        <td width="120">{$v[title]}<br/>{$v[par]}</td>
        <td width="120">{$v[adddate]}</td>
        <td width="60">{$v[amount]}</td>
        <td width="120">{$DT[money_sign]}{$v[price]}</td>
        <td width="120">{$v[adddate]}</td>
        <td width="120">{$v[company]}</td>
         <td width="100">{if $v[status] == '3'}待合并{/if}{if $v[status] == '7'}已合并{/if}</td>
    </tr>
{/loop}
</table>
    </div>
    {if $v[status] == '3'}
    <div class="btns">
        <input type="submit" value=" 合并选中 " class="btn" onclick="if(confirm('确定要合并选中订单吗？')){this.form.action='?action=merge'}else{return false;}"/>
    </div>
    {/if}
</form>
<div class="pages">{$pages}</div>
<script type="text/javascript">s('childcompany');m('order_list');</script>
{elseif $action == 'add'}
<div style="background-color:#cccccc;color:#ffffff; margin:10px 0px 10px 0px;padding: 10px;">
*作为集团型商家，可以添加子公司，对子公司进行管理，子公司发布的采购单由集团进行统一汇总发布，发布过后得到的报价与发布的
价格会产生价差，集团可以对子公司进行返利操作。
</div>
<form method="post" action="childcompany.php" onsubmit="return check();">
<input type="hidden" name="action" value="{$action}"/>
<table cellpadding="5" cellspacing="1" class="tb">
<tr>
    <td colspan="2"><h3>账户信息<h3></td>
</tr>
<tr>
<td class="tl"><span class="f_red">*</span> 会员类型</td>
<td class="tr"><input id="g_6" type="radio" checked="true" onclick="reg(1);" value="6" name="member[regid]">子公司</td>
</tr>
<tr>
<td class="tl"><span class="f_red">*</span> 会员登录名</td>
<td><input type="text" size="20" name="member[username]" id="username" onblur="validator('username');"/>&nbsp;<span id="dusername" class="f_red"></span></td>
</tr>
<tr>
<tr>
<tr>
<td class="tl"><span class="f_red">*</span> 登录密码</td>
<td><input type="password" size="20" name="member[password]" id="password" onblur="validator('password');" autocomplete="off"/>&nbsp;<span id="dpassword" class="f_red"></span></td>
</tr>
<tr>
<td class="tl"><span class="f_red">*</span> 重复输入密码</td>
<td><input type="password" size="20" name="member[cpassword]" id="cpassword" autocomplete="off"/>&nbsp;<span id="dcpassword" class="f_red"></span></td>
</tr>
<tr>
<tr>
    <td colspan="2"><h3>联系方式<h3></td>
</tr>
<tr>
<td class="tl"><span class="f_red">*</span> 真实姓名</td>
<td><input type="text" size="20" name="member[truename]" id="truename"/>&nbsp;<span id="dtruename" class="f_red"></span></td>
</tr>
<tr>
<td class="tl">性别</td>
<td>
<input type="radio" name="member[gender]" value="1" checked="checked"/> 先生
<input type="radio" name="member[gender]" value="2"/> 女士
</td>
</tr>
<tr>
<td class="tl">所在地区</td>
<td><?php echo ajax_area_select('member[areaid]', '请选择', 0, '', 2);?>&nbsp;<span id="dareaid" class="f_red"></span></td>
</tr>
<tr>
<td class="tl">部门</td>
<td><input type="text" size="20" name="member[department]" id="department"/></td>
</tr>
<tr>
<td class="tl">职位</td>
<td><input type="text" size="20" name="member[career]" id="career"/></td>
</tr><tr>
<td class="tl">手机号码</td>
<td><input type="text" size="20" name="member[mobile]" id="mobile"/></td>
</tr>
<td class="tl"><span class="f_red">*</span>Email</td>
<td><input type="text" size="20" name="member[email]" id="email"/></td>
</tr>
<tr>
<td class="tl">QQ</td>
<td><input type="text" size="20" name="member[qq]" id="qq"/></td>
</tr>

<tr>
    <td colspan="2"><h3>公司信息<h3></td>
</tr>
<tr>
<td class="tl"><span class="f_red">*</span>公司名称</td>
<td><input type="text" size="20" name="member[company]" id="company" onblur="validator('company');"/>&nbsp;<span id="dcompany" class="f_red"></span></td>
</tr>
<tr>
<td class="tl">公司类型</td>
<td><?php echo dselect($COM_TYPE, 'member[type]', '请选择', '', 'id="type"', 0);?>&nbsp;<span id="dtype" class="f_red"></span></td>
</tr>
<tr>
<td class="tl">公司规模</td>
<td><?php echo dselect($COM_SIZE, 'member[size]', '请选择规模', '', '', 0);?></td>
</tr>
<tr>
<td class="tl">公司电话</td>
<td><input type="text" size="20" name="member[telephone]" id="telephone"/>&nbsp;<span id="dtelephone" class="f_red"></span></td>
</tr>
<tr>
<td class="tl">&nbsp;</td>
<td class="tr" height="50"><input type="submit" name="submit" value=" 添 加 " class="btn_g"/></td>
</tr>
</table>
</form>
<script type="text/javascript">s('childcompany');m('add');</script>
{elseif $action == 'edit'}
<form method="post" action="childcompany.php" onsubmit="return check();">
<input type="hidden" name="action" value="{$action}"/>
<input type="hidden" name="itemid" value="{$itemid}"/>
<table cellpadding="5" cellspacing="1" class="tb">
<tr>
    <td colspan="2"><h3>账户信息<h3></td>
</tr>
<tr>
<td class="tl"><span class="f_red">*</span> 会员类型</td>
<td class="tr"><input id="g_6" type="radio" checked="true" onclick="reg(1);" value="6" name="member[regid]">子公司</td>
</tr>
<tr>
<td class="tl"><span class="f_red">*</span> 会员登录名</td>
<td><input type="text" value="{$username}" size="20" name="member[username]" id="username" onblur="validator('username');"/>&nbsp;<span id="dusername" class="f_red"></span></td>
</tr>
<tr>
<tr>
<tr>
<tr>
    <td colspan="2"><h3>联系方式<h3></td>
</tr>
<tr>
<td class="tl"><span class="f_red">*</span> 真实姓名</td>
<td><input type="text" size="20" value="{$truename}" name="member[truename]" id="truename"/>&nbsp;<span id="dtruename" class="f_red"></span></td>
</tr>
<tr>
<td class="tl">性别</td>
<td>
<input type="radio" name="member[gender]" value="1" {if $gender==1}checked="checked"{/if} /> 先生
<input type="radio" name="member[gender]" value="2"{if $gender==2}checked="checked"{/if} /> 女士
</td>
</tr>
<tr>
<td class="tl">所在地区</td>

<td><?php echo ajax_area_select('post[areaid]', '请选择', $areaid);?>&nbsp;<span id="dareaid" class="f_red"></span></td>
</tr>
<tr>
<td class="tl">部门</td>
<td><input type="text" size="20" value="{$department}" name="member[department]" id="department"/></td>
</tr>
<tr>
<td class="tl">职位</td>
<td><input type="text" size="20" value="{$career}" name="member[career]" id="career"/></td>
</tr><tr>
<td class="tl">手机号码</td>
<td><input type="text" size="20" value="{$mobile}" name="member[mobile]" id="mobile"/></td>
</tr>
<td class="tl">Email</td>
<td><input type="text" size="20" value="{$email}" name="member[email]" id="email"/></td>
</tr>
<tr>
<td class="tl">QQ</td>
<td><input type="text" size="20" value="{$qq}" name="member[qq]" id="qq"/></td>
</tr>

<tr>
    <td colspan="2"><h3>公司信息<h3></td>
</tr>
<tr>
<td class="tl"><span class="f_red">*</span>公司名称</td>
<td><input type="text" size="20" value="{$company}" name="member[company]" id="company" onblur="validator('company');"/>&nbsp;<span id="dcompany" class="f_red"></span></td>
</tr>
<tr>
<td class="tl">公司类型</td>
<td><?php echo dselect($COM_TYPE, 'member[type]', '请选择类型', $type, '', 0);?>&nbsp;<span id="dtype" class="f_red"></span></td>
</tr>
<tr>
<td class="tl">公司规模</td>
<td><?php echo dselect($COM_SIZE, 'member[size]', '请选择规模', $size, '', 0);?></td>
</tr>
<tr>
<td class="tl">公司电话</td>
<td><input type="text" size="20" value="{$telephone}" name="member[telephone]" id="telephone"/>&nbsp;<span id="dtelephone" class="f_red"></span></td>
</tr>
<tr>
<tr>
<td class="tl">&nbsp;</td>
<td class="tr" height="50"><input type="submit" name="submit" value=" 修 改 " class="btn_g"/>&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" value=" 取 消 " class="btn" onclick="history.back(-1);"/></td>
</tr>
</table>
</form>
<script type="text/javascript">s('childcompany');m('home');</script>
{else}
<div class="tt">
&nbsp;{$fields_select}&nbsp;
<input type="text" size="50" name="kw" value="{$kw}" title="关键词"/>&nbsp;
<input type="submit" value=" 搜 索 " class="btn"/>
<input type="button" value=" 重 搜 " class="btn" onclick="Go('childcompany.php');"/>
</div>
</form>
<div class="ls">
    <form method="post">
        <table cellpadding="8" cellspacing="0" class="tb">
    <tr bgcolor="#F2F2F2" align="center">
        <th width="120">公司名称</th>
        <th width="120">会员名称</th>
        <th width="60">手机号码</th>
        <th width="120">添加时间</th>
       <!-- <th width="120">采购量(元)</th>-->
        <th width="120">管理</th>
    </tr>

{loop $lists $k $v}
{if $v}
<tr  align="center">
<td height="120"><strong>{$v[company]}</strong></td>
<td height="120">{$v[truename]} {if $v[department]} ({$v[department]}){/if}  {if $v[career]} ({$v[career]}){/if}</td>
<td height="60">{$v[mobile]}</td>
<td height="120">{timetodate($v[regtime], 5)}</td>
 <!-- <td height="120">采购量</td>-->
 <td height="120">
<a href="?action=edit&itemid={$v[userid]}" class="t">[修改]</a>&nbsp;
<a href="?action=delete&itemid={$v[userid]}" onclick="return confirm('确定要删除吗？此操作将不可撤销');" class="t">[删除]</a>&nbsp;
</span>
</td>
</tr>
{/if}
{/loop}
</table>
 </div>

<div class="pages">{$pages}</div>
<script type="text/javascript">s('childcompany');m('home');</script>
{/if}
{if $action=='add' || $action=='edit'}
<script type="text/javascript">
function check() {
	if(Dd('username').value == '') {
		Dmsg('请填写会员登录名', 'username');
		return false;
	}
	if(Dd('password').value == '') {
		Dmsg('请填写会员登录密码', 'password');
		return false;
	}
	if(Dd('cpassword').value == '') {
		Dmsg('请重复输入密码', 'cpassword');
		return false;
	}
	if(Dd('password').value != Dd('cpassword').value) {
		Dmsg('两次输入的密码不一致', 'password');
		return false;
        }
        
	if(Dd('truename').value == '') {
		Dmsg('请填写真实姓名', 'truename');
		return false;
	}
            
        if(Dd('company').value == '') {
                Dmsg('请填写公司名称', 'company');
                return false;
        }
        if(Dd('type').value == '') {
                Dmsg('请选择公司类型', 'type');
                return false;
        }
        
	return true;
}
</script>
{/if}
{template 'footer', $module}
{/if}

